package com.homework;

import com.reflex.annotations.AutoRunClass;
import com.reflex.annotations.AutoRunMethod;

import java.util.Objects;

@AutoRunClass
public class Person {
    private String name = "张三";
    private int age;

    public Person() {
    }

    public Person(String name) {
        this.name = name;
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }
    @AutoRunMethod(3)//这里注解的value属性默认值为1，如果只有一个参数，可以省略value属性
    public void sayHello() {
        System.out.println(name + ":Hello");
    }

    @AutoRunMethod(value = 2)
    public void sayHi() {
        System.out.println(name + ":Hi");
    }

    @AutoRunMethod(value = 13)
    public void doSome() {
        System.out.println(name + ":做某事");
    }

    @AutoRunMethod(value = 10)
    public void sellp() {
        System.out.println(name + ":睡觉");
    }

    public void watchTVs() {
        System.out.println(name + ":看电视");
    }

    public void study() {
        System.out.println(name + ":在学习");
    }

    public void playGame() {
        System.out.println(name + ":在玩游戏");
    }

    public void sing() {
        System.out.println(name + ":在唱歌");
    }

    public void say(String info) {
        System.out.println(name + ":" + info);
    }

    public void say(String info, int count) {
        for (int i = 0; i < count; i++) {
            System.out.println(name + ":" + info);
        }
    }

    private void hihi() {
        System.out.println("我是Person的私有方法hihi");
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return age == person.age && Objects.equals(name, person.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
}
